jQuery.fn.mwindow = function(option){

 var option=jQuery.extend({
	 width: '150px', // бэкграунд для четных строк
	 height: '100px', // бэкграунд для нечетных строк
	 left: '100', // цвет шрифта четных строк
	 top: '100', // цвет шрифта нечетных строк
	 name: '', // бэкграунд при hover
	 context: '',
	 closeClass:'mwClose',
	 submit:true,
	 success:function(e){},
	 trigger:'',
	 url:''
 	},option);
 	return this.each(function() 
 			{
 				$(this).html(	'<div class="mWdrag ui-widget ui-widget-content ui-corner-all ui-jqdialog" height= '+(parseInt(option.height)+65)+'px  style="overflow-x: hidden; overflow-y: hidden; top: '+option.top+'px; left: '+option.left+'px;display:block; z-index: 950; width: '+option.width+'px; " tabindex="-1" >'+
 								'<div class="ui-jqdialog-titlebar ui-widget-header ui-corner-all ui-helper-clearfix" id="edithdtable1" style="cursor: move; ">'+
 								'	<span class="ui-jqdialog-title" style="float: left; ">'+option.name+'</span>'+
 								'		<a href="javascript:void(0)" class="'+option.closeClass+' ui-corner-all" style="float:right">'+
 								'			<span class="ui-icon ui-icon-closethick"></span>'+
 								'		</a>'+
 								'</div>'+
 								'<div class="ui-jqdialog-content ui-widget-content" id="editcnttable1">'+
 								'<span>'+
 								'<div class="mwForm" width= '+option.width+'px  height='+(parseInt(option.height))+'px >'+
 								'	<form name="FormPost" id="mWFormId" onsubmit="return false;" class="mWForm"  style="overflow-x: auto; overflow-y: auto; position: relative; ">'+
 										option.context+
 								'	</form>'+
 								'</div>'+
 								'<table border="0" cellspacing="0" cellpadding="0" class="EditTable" id="TblGrid_table1_2">'+
 								'<tbody>'+
 								'	<tr>'+
 								'		<td colspan="2">'+
 								'		<hr class="ui-widget-content" style="margin:1px">'+
 								'		</td>'+
 								'	</tr>'+
 								'<tr id="Act_Buttons">'+
 								'	<td class="navButton">'+
 								'		<a href="javascript:void(0)" id="pData" class="fm-button ui-state-default ui-corner-left" style="display: none; ">'+
 								'			<span class="ui-icon ui-icon-triangle-1-w"></span>'+
 								'		</a>'+
 								'		<a href="javascript:void(0)" id="nData" class="fm-button ui-state-default ui-corner-right" style="display: none; ">'+
 								'			<span class="ui-icon ui-icon-triangle-1-e"></span>'+
 								'		</a>'+
 								'	</td>'+
 								'	<td class="EditButton">'+
 								'		<a href="javascript:void(0)" id="sData" class="submitClass fm-button ui-state-default ui-corner-all fm-button-icon-left">'+
 								'			Сохранить'+
 								'			<span class="ui-icon ui-icon-disk"></span>'+
 								'		</a>'+
 								'		<a href="javascript:void(0)" id="cData" class="'+option.closeClass+' fm-button ui-state-default ui-corner-all fm-button-icon-left">'+
 								'			Отмена'+
 								'			<span class="ui-icon ui-icon-close"></span>'+
 								'		</a>'+
 								'	</td>'+
 								'</tr>'+
 								'<tr style="display: none; " class="binfo">'+
 								'	<td class="bottominfo" colspan="2">	</td>'+
 								'</tr>'+
 								'</tbody>'+
 								'</table>'+
 								'</span>'+
 								'</div>'+
 								'</div>');

 				var temp=this;
 				this.setHeight=function(h)
 				{
 					option.height=h;
 				}
 				
 				$(this).attr("style",'display:none');
 				$('.mWdrag',this).draggable(); 
 				
 				$('.'+option.trigger).click(function(){
 					$(temp).toggle();
 				});
 				$('.'+option.closeClass,this).click(function(){
 					$(temp).toggle();
 				});
 				if((option.url!="")&&(option.submit))
 					{
 					
	 					$('.submitClass',this).click(function(){
	 						$.ajax({
	 							  url: option.url,
	 							  type:'post',
	 							  data:$('#mWFormId',temp).serialize(),
	 							  success:option.success
	 							});
	 	 					
	 	 					$(temp).toggle();
	 	 				});
 					}
 				else
 					{
 						$('#sData',temp).attr('style','display:none');
 					
 					}
 				
 				
 			});
 	
};
